using System;
using full_leaf_framework.Effect;
using full_leaf_framework.Visual;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace touhou_bullet_rain;

public class RotateDust : Particle {

    public float rotateSpeedRatio;

    public override void BeginParticle(ParticleController particleController, AnimatedSprite currentAnimation, Vector2 pos, Vector2 anchorPoint, float sizeScale, Vector2 velocity,
    float lifeTime, string[] extArugs, float angle = 0, SpriteEffects effects = SpriteEffects.None, int layer = 10) {
        base.BeginParticle(particleController, currentAnimation, pos, anchorPoint, sizeScale, velocity,
        lifeTime, extArugs, effects: effects);
        drawable.angle = (float)(new Random().NextDouble() * 2 * MathF.PI);
        rotateSpeedRatio = (float)new Random().NextDouble() * 2.5f + 0.5f;
    }

    public override void Update(GameTime gameTime) {
        base.Update(gameTime);
        velocity *= 0.98f;
        if (velocity.Length() < 1f) { velocity = Vector2.Zero; }
        drawable.angle += rotateSpeedRatio * MathF.PI
            * (float)gameTime.ElapsedGameTime.TotalSeconds;
    }

}
